
import {
    createRouter,
    createWebHistory,
    RouteRecordRaw
} from 'vue-router';
import { routes, homeRoutes } from './routes';

const router = createRouter({
    history: createWebHistory(`/${import.meta.env.VITE_BASE}/`),
    routes: routes as Array<RouteRecordRaw>
});

// 路由守卫，处理鉴权
// router.beforeEach(async (to, from) => {
//     if (!whiteRouteList.includes(to.name)) {
//       const token = sessionStorage.getItem('token')
//       if (!token) {
//         // 将用户重定向到登录页面
//         return { name: 'login' }
//       }
//     }
// })


export {
    router,
    routes,
    homeRoutes
}

export default router
